document.addEventListener('DOMContentLoaded', () => {
    document.getElementById('registerForm').addEventListener('submit', function(event) {
        event.preventDefault();
        let username = document.getElementById('register-username').value;
        let password = document.getElementById('register-password').value;
        let confirmedPassword = document.getElementById('confirmed-register-password').value;
        let nickname = document.getElementById('register-nickname').value;

        if(password !== confirmedPassword) {
            alert('密码不一致，请重新输入');
            return;
        }

        if(register(nickname, username, password)) {
            alert("注册成功");
            window.location.href = 'main.html';
        }
    });

})
